CREATE TABLE [dbo].[tb_TramitesDocumentos]
(
[idTramite] [int] NOT NULL IDENTITY(1, 1),
[Proceso] [int] NULL,
[NroDeSubtramites] [int] NOT NULL,
[Descripcion] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Solicito] [int] NOT NULL,
[OrganizacionSolicitante] [int] NULL,
[AgenteSolicitante] [int] NULL,
[AlumnoSolicitante] [int] NULL,
[DescripcionSolicitante] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ResponsableProceso] [int] NOT NULL,
[FechaYHoraInicio] [datetime] NOT NULL,
[FechaYHoraFin] [datetime] NULL,
[TiempoTraslados] [int] NOT NULL,
[TiempoLatencia] [int] NOT NULL,
[Estado] [int] NOT NULL,
[TramiteOrigen] [int] NULL,
[Asunto] [int] NULL,
[Tipo] [int] NOT NULL,
[Numero] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tb_TramitesDocumentos] ADD CONSTRAINT [PK_tb_TramitesDocumentos] PRIMARY KEY NONCLUSTERED  ([idTramite]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tb_TramitesDocumentos] WITH NOCHECK ADD CONSTRAINT [FK_tb_TramitesDocumentos_tb_AsuntosDeTramite] FOREIGN KEY ([Asunto]) REFERENCES [dbo].[tb_AsuntosDeTramite] ([IDAsuntoDeTramite])
GO
ALTER TABLE [dbo].[tb_TramitesDocumentos] WITH NOCHECK ADD CONSTRAINT [FK_tb_TramitesDocumentos_tb_EstadosDeTramites] FOREIGN KEY ([Estado]) REFERENCES [dbo].[tb_EstadosDeTramites] ([idEstadoTramite])
GO
ALTER TABLE [dbo].[tb_TramitesDocumentos] WITH NOCHECK ADD CONSTRAINT [FK_tb_TramitesDocumentos_tb_Organizaciones] FOREIGN KEY ([OrganizacionSolicitante]) REFERENCES [dbo].[tb_Organizaciones] ([idOrganizaciones])
GO
ALTER TABLE [dbo].[tb_TramitesDocumentos] WITH NOCHECK ADD CONSTRAINT [FK_tb_TramitesDocumentos_tb_Procesos] FOREIGN KEY ([Proceso]) REFERENCES [dbo].[tb_Procesos] ([idProceso])
GO
ALTER TABLE [dbo].[tb_TramitesDocumentos] WITH NOCHECK ADD CONSTRAINT [FK_tb_TramitesDocumentos_tb_Usuarios1] FOREIGN KEY ([ResponsableProceso]) REFERENCES [dbo].[tb_Usuarios] ([idUsuario])
GO
ALTER TABLE [dbo].[tb_TramitesDocumentos] WITH NOCHECK ADD CONSTRAINT [FK_tb_TramitesDocumentos_tb_Usuarios] FOREIGN KEY ([Solicito]) REFERENCES [dbo].[tb_Usuarios] ([idUsuario])
GO
ALTER TABLE [dbo].[tb_TramitesDocumentos] WITH NOCHECK ADD CONSTRAINT [FK_tb_TramitesDocumentos_tb_TiposDeTramites] FOREIGN KEY ([Tipo]) REFERENCES [dbo].[tb_TiposDeTramites] ([IDTipoDetramite])
GO
ALTER TABLE [dbo].[tb_TramitesDocumentos] WITH NOCHECK ADD CONSTRAINT [FK_tb_TramitesDocumentos_tb_TramitesDocumentos] FOREIGN KEY ([TramiteOrigen]) REFERENCES [dbo].[tb_TramitesDocumentos] ([idTramite])
GO
